	<body>
	<div class="header" style="height:76px;"><a href="index.?action=home"></a></div>
	 <h3 class='title'>Resize Image</h3>
	<?php
	require_once('database/auth.php');
	?>

	<?php
	include_once('templates/header.php');
	include_once ('templates/nav.php');
	?>
	<?php

	$fileName = $_FILES["uploaded_file"]["name"]; 
	$fileTmpLoc = $_FILES["uploaded_file"]["tmp_name"]; 
	$fileType = $_FILES["uploaded_file"]["type"]; 
	$fileSize = $_FILES["uploaded_file"]["size"]; 
	$fileErrorMsg = $_FILES["uploaded_file"]["error"]; 
	$kaboom = explode(".", $fileName); 
	$fileExt = end($kaboom);
	$fileName = preg_replace('#[^a-z.0-9]#i', '', $fileName); 
	$kaboom = explode(".", $fileName);
	$fileExt = end($kaboom); 

	if (!$fileTmpLoc) { 
		echo "ERROR: Please browse for a file before clicking the upload button.";
		exit();
	} else if($fileSize > 5242880) { 
		echo "ERROR: Your file was larger than 5 Megabytes in size.";
		unlink($fileTmpLoc); 
		exit();
	} else if (!preg_match("/.(gif|jpg|png)$/i", $fileName) ) {
		 echo "ERROR: Your file was not .gif, .jpg, or .png.";
		 unlink($fileTmpLoc); 
		 exit();
	} else if ($fileErrorMsg == 1) { 
		echo "ERROR: An error occured while processing the file. Try again.";
		exit();
	}

	$moveResult = move_uploaded_file($fileTmpLoc, "uploads/$fileName");

	if ($moveResult != true) {
		echo "ERROR: File not uploaded. Try again.";
		unlink($fileTmpLoc); 
		exit();
	}
	include_once("resize_func.php");
	$target_file = "uploads/$fileName";
	$resized_file = "uploads/resized_$fileName";
	$wmax = 300;
	$hmax = 300;
	ak_img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt);

	$target_file = "uploads/resized_$fileName";
	$thumbnail = "uploads/thumb_$fileName";
	$wthumb = 150;
	$hthumb = 150;
	ak_img_thumb($target_file, $thumbnail, $wthumb, $hthumb, $fileExt);

	list($width, $height, $fileType, $attr) = getimagesize("$target_file");
	list($width, $height, $fileType, $attr2) = getimagesize("$thumbnail");
	
	echo "<a title='Resized Image'><img src='$resized_file'/></a>"."  ";
	echo "<br/><br/>";
	echo "Download Link:<a title='Download' href='$resized_file'><strong>Resized Image</strong></a><br />";
	echo "<a style='color:grey;font-size:12px;'>(  Note! Right Click on the Link and select Save link as...  )</a><br/><br/>";
	echo "Dimension: $attr<br />";
	echo "<br/>";	
	echo "<a title='Thumbnail'><img src='$thumbnail'/></a><br />";
	echo "<br/>";
	echo "Download Link:<a title='Download' href='$thumbnail'><strong>Thumbnail</strong></a><br />";
	echo "<a style='color:grey;font-size:12px;'>(  Note! Right Click on the Link and select Save link as... )</a><br/><br/>";
	echo "Dimension: $attr2";
	echo "<br/>";
	/*
	echo "The file named <strong>$fileName</strong> uploaded successfuly.<br /><br />";
	echo "It is <strong>$fileSize</strong> bytes in size.<br /><br />";
	echo "It is an <strong>$fileType</strong> type of file.<br /><br />";
	echo "The file extension is <strong>$fileExt</strong><br /><br />";
	echo "The Error Message output for this upload is: $fileErrorMsg";
	*/
	?>
	<?php include_once ('templates/footer.php');?>